import org.apache.commons.lang.StringUtils;
/**
 * @author zhouzhiheng98@foxmail.com 2020-07-22 11:18:52
 */
public class Method {
    public static void main(String[] args) {
        PersonMethod ming = new PersonMethod();
        // 对字段name赋值
        ming.setName("Xiao Ming");
        // 对字段age赋值
        ming.setBirth(1998);
        System.out.println(ming.getName() + ", " + ming.getAge());
    }
}

class PersonMethod{
    private String name;
//    private int age;
    private int birth;

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        if (name == null || StringUtils.isBlank(name)) {
            throw new IllegalArgumentException("invalid name");
        }
        // 去掉首尾空格
        this.name = StringUtils.strip(name);
    }

    public int getAge() {
//        return this.age;
        return calcAge(2020);
    }

    private int calcAge(int currentYear) {
        return currentYear - this.birth;
    }

    public void setAge(int age) {
        if (age < 0 || age > 100) {
            throw new IllegalArgumentException("invalid age value");
        }
//        this.age = age;
    }

    public void setBirth(int birth) {
        this.birth = birth;
    }
}
